<template>
	<view class="nav-bar">
		<view :style="{ height: statusBarHeight }"></view>
		<view class="bar">
			<view class="left-icon" v-if="leftIcon"
				@click="leftClick">
				 <uni-icons size="21" type="back" :color="leftIconColor"></uni-icons>
			</view>
			<view class="left-icon" v-if="!leftIcon">
			 
			</view>
			<view class="content" v-if="centerTitle" :style="{color:centerTitleColor}">
				{{centerTitle}}
			</view>
			<view class="right-icon"></view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "nav-bar",
		props: {
			leftIconColor:{
				type: String,
				default:'#000',
			},
			leftIcon: {
				type: Boolean,
				default: true, 
			},
			centerTitle: {
				type: String,
				default: '',
			},
			centerTitleColor:{
				type:String,
				default:"#000",
			}
		},
		data() {
			return {
				statusBarHeight: 20
			};
		},
		mounted() {
			this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'
		},
		methods:{
			leftClick(){
				this.$tools.pagesBack()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.nav-bar {
		height: 20px;
		position: fixed;
		width: 100%;
		z-index: 999;
	}

	.bar {
		height: 37px;
		display: flex;
		align-items: center;
	}

	.left-icon {
		width: 60rpx;
		margin-left: 16rpx;
		height: 37px;
		display: flex;
		align-items: center;
		justify-content: center;

		.left-icon-img {
			width: 38rpx;
			height: 38rpx;
		}
	}

	.content {
		width: 598rpx;
		height: 37px;
		font-size: 32rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.right-icon {
		margin-right: 16rpx;
		width: 60rpx;
	}
</style>